<!--
 * @Description  : 预览
 * @Author       : zhao
 * @Date         : 2022-07-20 09:38:05
 * @LastEditors  : zhao
 * @LastEditTime : 2023-01-16 14:44:45
-->

<template>
    <div class="Preview" v-if="dialogVisible">
        <el-dialog :close-on-click-modal="false" :visible.sync="dialogVisible" :fullscreen="true" title="文件预览">
            <div class="agreement_picture">
                <zpdf ref="pdf" v-if="preview.type == 'application/pdf'" />
                <zdocx v-if="preview.type == 'application/msword'" />
                <img v-if="preview.type == 'image/jpeg'" :src="preview.url" alt="" />
                <img v-if="preview.type == 'image/png'" :src="preview.url" alt="" />
            </div>
        </el-dialog>
    </div>
</template>

<script>
import zpdf from "./zPDF/index.vue"
import zdocx from "./docx.vue"
export default {
    name: "",
    data() {
        return {
            dialogVisible: false,
            preview: {},
        }
    },

    // props: {
    //     preview: Object
    // },
    watch: {
        "$store.state.borrowForm.previewType": {
            handler: function (val, oldVal) {
                this.preview = val
            },
            immediate: true,
            deep: true,
        },
    },
    components: { zpdf, zdocx },

    computed: {},

    mounted() {},

    methods: {
        open(val) {
            if (val.type == "application/pdf") {
            }
            // console.log("🚀 ~ file: index.vue ~ line 53 ~ open ~ this.$refs['application/pdf']", this.$refs["application/pdf"])
            // this.$refs['application/pdf'].goPreview()
        },
    },
}
</script>
<style lang='scss' scoped>
</style>